<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.linenumber {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='linenumber'>  1</span> <span class="COMM">/***************************************************************************************************/</span><span class="WHIT">
<span class='linenumber'>  2</span> 
<span class='linenumber'>  3</span> </span><span class="COMM">//Namespace 2112</span><span class="WHIT">
<span class='linenumber'>  4</span> </span><span class="COMM">//Create Object Node if not already done.</span><span class="WHIT">
<span class='linenumber'>  5</span> </span><span class="NAME">window.NS2112</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.NS2112</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'>  6</span> 
<span class='linenumber'>  7</span> 
<span class='linenumber'>  8</span> </span><span class="NAME">NS2112.CustomEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oScope</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">silent</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">signature</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="WHIT">
<span class='linenumber'>  9</span> </span><span class="PUNC">{</span><span class="WHIT">  </span><span class="COMM">//this is just an encapsulation and in the future the YAHOO CE should be eradicated.</span><span class="WHIT">
<span class='linenumber'> 10</span> </span><span class="WHIT">   </span><span class="NAME">this.ce</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">YAHOO.util.CustomEvent</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">oScope</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">silent</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">signature</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 11</span> 
<span class='linenumber'> 12</span> </span><span class="WHIT">   </span><span class="NAME">this.subscribe</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">override</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 13</span> </span><span class="WHIT">      </span><span class="NAME">this.ce.subscribe</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">override</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 14</span> </span><span class="WHIT">   </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="WHIT">
<span class='linenumber'> 15</span> 
<span class='linenumber'> 16</span> </span><span class="WHIT">   </span><span class="NAME">this.unsubscribe</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT">  </span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 17</span> </span><span class="WHIT">      </span><span class="NAME">this.ce.unsubscribe</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="WHIT"> </span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 18</span> </span><span class="WHIT">   </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="WHIT">
<span class='linenumber'> 19</span> 
<span class='linenumber'> 20</span> </span><span class="WHIT">   </span><span class="NAME">this.fire</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 21</span> </span><span class="WHIT">      </span><span class="NAME">this.ce.fire</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 22</span> </span><span class="WHIT">   </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 23</span> 
<span class='linenumber'> 24</span> </span><span class="WHIT">   </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.ce</span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 25</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 26</span> 
<span class='linenumber'> 27</span> 
<span class='linenumber'> 28</span> </span><span class="NAME">NS2112.clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">myObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='linenumber'> 29</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 30</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">myObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">myObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 31</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">myObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">myObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 32</span> 
<span class='linenumber'> 33</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">myNewObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Object</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 34</span> 
<span class='linenumber'> 35</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">myObj</span><span class="PUNC">)</span><span class="WHIT">
<span class='linenumber'> 36</span> </span><span class="WHIT">		</span><span class="NAME">myNewObj</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">NS2112.clone</span><span class="PUNC">(</span><span class="NAME">myObj</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 37</span> 
<span class='linenumber'> 38</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">myNewObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 39</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 40</span> 
<span class='linenumber'> 41</span> 
<span class='linenumber'> 42</span> </span><span class="NAME">NS2112.include</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">file</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 43</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">script</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">'script'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 44</span> </span><span class="WHIT">  </span><span class="NAME">script.src</span><span class="WHIT">  </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">file</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 45</span> </span><span class="WHIT">  </span><span class="NAME">script.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'text/javascript'</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 46</span> 
<span class='linenumber'> 47</span> </span><span class="WHIT">  </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">'head'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">item</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">appendChild</span><span class="PUNC">(</span><span class="NAME">script</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 48</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 49</span> 
<span class='linenumber'> 50</span> 
<span class='linenumber'> 51</span> </span><span class="COMM">//Now we can use the NS2112.</span><span class="WHIT">
<span class='linenumber'> 52</span> </span><span class="COMM">//This namespace will be used later for declaring Classes within it.</span><span class="WHIT">
<span class='linenumber'> 53</span> 
<span class='linenumber'> 54</span> </span><span class="NAME">NS2112.namespace</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 55</span> 
<span class='linenumber'> 56</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">ns</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ns.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 57</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 58</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 59</span> 
<span class='linenumber'> 60</span> 
<span class='linenumber'> 61</span> 
<span class='linenumber'> 62</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">levels</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ns.split</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 63</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">nsobj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">NS2112</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 64</span> 
<span class='linenumber'> 65</span> </span><span class="WHIT">    </span><span class="COMM">// NS2112 is implied, so it is ignored if it is included</span><span class="WHIT">
<span class='linenumber'> 66</span> </span><span class="WHIT">    </span><span class="COMM">// Creating sublevels if not already done so.</span><span class="WHIT">
<span class='linenumber'> 67</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="PUNC">(</span><span class="NAME">levels</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"NS2112"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">levels.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 68</span> </span><span class="WHIT">        </span><span class="NAME">nsobj</span><span class="PUNC">[</span><span class="NAME">levels</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nsobj</span><span class="PUNC">[</span><span class="NAME">levels</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">  </span><span class="COMM">//create empty object if necessary</span><span class="WHIT">
<span class='linenumber'> 69</span> </span><span class="WHIT">        </span><span class="NAME">nsobj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nsobj</span><span class="PUNC">[</span><span class="NAME">levels</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 70</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 71</span> 
<span class='linenumber'> 72</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">nsobj</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 73</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 74</span> 
<span class='linenumber'> 75</span> </span><span class="COMM">//Extending by prototypal inheritance using this function.</span><span class="WHIT">
<span class='linenumber'> 76</span> </span><span class="NAME">NS2112.extend</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">subclass</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">superclass</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 77</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">f</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 78</span> </span><span class="WHIT">    </span><span class="NAME">f.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">superclass.prototype</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 79</span> </span><span class="WHIT">    </span><span class="NAME">subclass.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 80</span> </span><span class="WHIT">    </span><span class="NAME">subclass.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">subclass</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 81</span> </span><span class="WHIT">    </span><span class="NAME">subclass.superclass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">superclass.prototype</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 82</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">superclass.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Object.prototype.constructor</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='linenumber'> 83</span> </span><span class="WHIT">        </span><span class="NAME">superclass.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">superclass</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 84</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='linenumber'> 85</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='linenumber'> 86</span> 
<span class='linenumber'> 87</span> </span><span class="NAME">NS2112.namespace</span><span class="PUNC">(</span><span class="STRN">"NS2112"</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>